<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>添加销售退单</title>
	<link href="<%=path%>/css/style_min.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/core.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/form.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/list.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/SupplierSelect.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/UsersSelect.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/xWindowPanel.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/xToolbar.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
    input { width: 180px;}
    textarea { width: 503px; height: 40px;}
    select { width: 188px;}
    .n { text-align: right;}
    .required {color:red;}
    </style>
  </head>
  <body>
    <form name="salesBackOrderForm" id="salesBackOrderForm" action="<%=path%>/sales/salesBackOrder/save.t4m" class="form" method="post">
      <div class="form-group">基本信息</div>
      <table class="form-table" cellspacing="0" cellpadding="0" width="100%">
        <tr>
          <td class="form-left"><span class="form-required">*</span>退货单编号</td>
          <td class="form-right"><input type="text" name="salesBackOrder.code" class="text required"/></td>
          <td class="form-left"><span class="form-required">*</span>退货日期</td>
          <td class="form-right"><input type="text" name="salesBackOrder.backDate" class="Wdate text f required" onclick="new WdatePicker();"/></td>
        </tr>
        <tr>
          <td class="form-left"><span class="form-required">*</span>退货原因</td>
          <td class="form-right"><input type="text" name="salesBackOrder.reason" class="text required"/></td>
          <td class="form-left"><span class="form-required">*</span>操作人</td>
          <td class="form-right"><input type="hidden" name="salesBackOrder.operator.id" id="operatorId" value="<s:property value="#session['LoginBean'].user.id" />"/></td>
        </tr>
      </table>
      
      <div class="form-group">退货单明细</div>
      <div id="toolbar"></div>
      <table id="titleTable" cellpadding="0" cellspacing="0">
        <tr>
          <td>销售订单编号</td>
          <td>销售日期</td>
          <td>货品编号</td>
          <td>货品名称</td>
          <td><span class="required">*</span>退货数量(个)</td>
          <td>取消</td>
        </tr>
      </table>
	<div style="overflow-y: scroll; height: 220px">
      <table id="dataTable" cellpadding="0" cellspacing="0"></table>
      </div>
      <s:hidden name="tabId"/>
      <s:hidden name="windowPanelId"/>
    </form>
    <script src="<%=path%>/js/prototype_for_validation.js" type="text/javascript"></script>
    <script src="<%=path%>/js/validation_cn.js" type="text/javascript"></script>
    <script src="<%=path%>/js/core.js" type="text/javascript"></script>
    <script src="<%=path%>/js/share.js" type="text/javascript"></script>
    <script src="<%=path%>/js/jquery.js" type="text/javascript"></script>
    <script src="<%=path%>/js/Validate.js" type="text/javascript"></script>
    <script src="<%=path%>/js/datePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="<%=path%>/js/SupplierSelect.js" type="text/javascript"></script>
    <script src="<%=path%>/js/UsersSelect.js" type="text/javascript"></script>
    <script src="<%=path%>/js/xWindowPanel.js" type="text/javascript"></script>
    <script src="<%=path%>/js/Draggable.js" type="text/javascript"></script>
    <script src="<%=path%>/js/xToolbar.js" type="text/javascript"></script>
    <script src="<%=path%>/js/xToolbar.items.js" type="text/javascript"></script>
    <script src="<%=path%>/js/modules/salesOrder.js" type="text/javascript"></script>
	<script src="<%=path%>/js/Grid.js" type="text/javascript"></script>
    <script type="text/javascript" src="<%=path%>/js/BoxSelect.js"></script>
	<script src="<%=path%>/js/jquery-impromptu.js" type="text/javascript"></script>
    <script type="text/javascript">
	var valid = new Validation('salesBackOrderForm',{immediate:true});
    var indexNum=0,grid;
    
    $(document).ready(function(){
      new Toolbar({
          renderTo : 'toolbar',
          icon: '../../image/op.gif',
          border:'both',
          items : [{
            type : 'button',
            text : '提取',
            tip : '提取退货货品',
            useable : 'T',
            position: {
              a: '0px 0px',
              b: '0px -120px'
            },
            handler : function(){
            	salesOrder.choose();
            }
          }]
        });
      
      grid = new Grid({
        titleTable:'titleTable',
        dataTable:'dataTable',
        widths : [120,120,90,120,70,70],
        height : 268
      });
      
      loadReady();
      new UsersSelect({
        url : '<%=path%>/system/ajax/listUsersByCondition.t4m',
        inputId : 'operatorId',
        title : '选择业务员',
        width : 184,
        multiple : false,
        selected : $('#operatorId').val()
      });
    });

    function addData(dataArray) {
        var table = $('#dataTable');
        for(var i=0,len=dataArray.length; i<len; ++i){
          if($('#'+dataArray[i].id).length){
            continue;
          }
          var htmlString = [];
          htmlString.push('<tr class="row" id="'+dataArray[i].id+'">');
          htmlString.push('<td><span>'+dataArray[i].sCode+'</span></td>');
          htmlString.push('<td><span>'+dataArray[i].sDate+'</span></td>');
          htmlString.push('<td><span>'+dataArray[i].pCode+'</span></td>');
          htmlString.push('<td><span>'+dataArray[i].pName+'</span></td>');
          htmlString.push('<td><input type="text" class="text n required"  name="backAmountsList" id="back'+indexNum+'" style="width:62px;text-align:right;margin-left:0px;"/></td>');
          htmlString.push('<td><div align="center" class="quick-button" style="background-position: -39px 0px;" onclick="delData(\''+dataArray[i].id+'\')"></div></td>');
          htmlString.push('<input type="hidden" name="salesOrderPoductIdList" value="'+dataArray[i].id+'"/>');
          htmlString.push('</tr>');
          table.append(htmlString.join(''));
          indexNum++;
        }
        if(grid){
         grid.updateWidth();
        }
      }
      
      function delData(id) {
        $('#'+id).remove();
        indexNum--;
      }
    </script>
  </body>
</html>